export function formatMobile(mobile: string) {
  if (!mobile) return ''
  return mobile.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2')
}

export function formatMoney(money: number | string = 0) {
  return Number(money).toFixed(2)
}

export function formatDay(day: string) {
  const date = new Date(day.replace(/-/g, '/'))
  return `${date.getMonth() + 1}.${date.getDate()}`
}

export function formatWeek(week: string) {
  const day = new Date(week.replace(/-/g, '/')).getDay()
  const weeks = ['日', '一', '二', '三', '四', '五', '六']
  return `星期${weeks[day]}`
}

const pad = (num: number) => num.toString().padStart(2, '0')

export function formatTime(time: string) {
  const date = new Date(time.replace(/-/g, '/'))
  return `${pad(date.getHours())}:${pad(date.getMinutes())}`
}
